package com.puzzlebazar.client.squaregrid.view;

import com.google.gwt.user.client.ui.Image;
import com.puzzlebazar.client.util.Vec2i;

public class ImageDrawable extends Drawable {
	
	/**
	 * Creates an image-based drawable
	 * 
	 * @param name Name of the drawable for future reference (can be null)
	 * @param url URL of the image to create in this drawable
	 */
	public ImageDrawable(String name, String url) {
		super(name);
		setImageUrl( url );
	}

	/**
	 * Creates an image-based drawable within a single cell
	 * 
	 * @param loc Location of the cell
	 * @param name Name of the drawable for future reference (can be null)
	 * @param url URL of the image to create in this drawable
	 */
	public ImageDrawable(Vec2i loc, String name, String url) {
		super(loc, name);
		setImageUrl( url );
	}

	/**
	 * Sets the URL of the image for this drawable. Must be set 
	 * once and never modified 
	 * 
	 * @param url The URL of the image
	 */
	private void setImageUrl( String url ) {
		setWidget( new Image( url ) );
	}
	
}
